﻿using System;
using System.Collections.Generic;
using System.Text;

using System.ComponentModel;
using System.Data;

using XCode;
using XCode.Attributes;
using XCode.Entity;

namespace XCMSData
{
	/// <summary>
	/// 权限映射
	/// </summary>
	public partial class PermissionMap : Entity
	{
        #region 事件
        #region 初始化
        /// <summary>
        /// 初始化 权限映射 对象时触发
        /// </summary>
        /// <param name="k">初始化位置，1是空参数，2是全参数，3是标识参数</param>
        private void OnInit(int k)
        {
        }
        #endregion

        #region 插入
        /// <summary>
        /// 插入前
        /// </summary>
        /// <returns>是否允许插入</returns>
        private static Boolean OnInserting()
        {
            return true;
        }

        /// <summary>
        /// 插入后
        /// </summary>
        /// <param name="retval">影响的行数</param>
        /// <returns>影响的行数</returns>
        private static Int32 OnInserted(Int32 retval)
        {
            hasUpdated = false;
            return retval;
        }

        /// <summary>
        /// 已重载。把该对象插入到数据库。
        /// </summary>
        /// <returns>影响的行数</returns>
        public override Int32 Insert()
        {
            if (!OnInserting()) return -1;
            return OnInserted(base.Insert());
        }
        #endregion

        #region 更新
        /// <summary>
        /// 更新前
        /// </summary>
        /// <returns>是否允许更新</returns>
        private static Boolean OnUpdating()
        {
            return true;
        }

        /// <summary>
        /// 更新后
        /// </summary>
        /// <param name="retval">影响的行数</param>
        /// <returns>影响的行数</returns>
        private static Int32 OnUpdated(Int32 retval)
        {
            hasUpdated = false;
            return retval;
        }

        /// <summary>
        /// 已重载。更新数据库。
        /// </summary>
        /// <returns>影响的行数</returns>
        public override Int32 Update()
        {
            if (!OnUpdating()) return -1;
            return OnUpdated(base.Update());
        }
        #endregion

        #region 删除
        /// <summary>
        /// 删除前
        /// </summary>
        /// <returns>是否允许删除</returns>
        private static Boolean OnDeleting()
        {
            return true;
        }

        /// <summary>
        /// 删除后
        /// </summary>
        /// <param name="retval">影响的行数</param>
        /// <returns>影响的行数</returns>
        private static Int32 OnDeleted(Int32 retval)
        {
            hasUpdated = false;
            return retval;
        }

        /// <summary>
        /// 已重载。从数据库中删除该对象
        /// </summary>
        /// <returns>影响的行数</returns>
        public override Int32 Delete()
        {
            if (!OnDeleting()) return -1;
            return OnDeleted(base.Delete());
        }
        #endregion
        #endregion
	}
}